home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / object / obj_axis.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  58 lines

  1. ;------------------------------------------------------------
  2. ; This procedure file defines the procedure obj_axis.pro,
  3. ; which is used as an example in Chapter 8 of _Objects and
  4. ; Object Graphics_.
  5. ;-------------------------------------------------------------
  6.  
  7. PRO obj_axis
  8.  
  9. ; Create some data.
  10. data = FINDGEN(100)
  11.  
  12. ; Create plot and axis objects.
  13. myplot = OBJ_NEW('IDLgrPlot', data)
  14. xaxis = OBJ_NEW('IDLgrAxis', 0)
  15. yaxis = OBJ_NEW('IDLgrAxis', 1)
  16.  
  17. ; Retrieve the data range from the plot object and set the X and Y
  18. ; axis objects' RANGE properly so that the axes will match the data
  19. ; when displayed:
  20. myplot -> GetProperty, XRANGE=xr, YRANGE=yr
  21. xaxis -> SetProperty, RANGE=xr
  22. yaxis -> SetProperty, RANGE=yr
  23.  
  24. ; By default, major tickmarks are 0.2 data units in length. Since
  25. ; the data range in this example is 0 to 99, we set the tick length
  26. ; to 2% of the data range instead:
  27. xtl = 0.02 * (xr[1] - xr[0])
  28. ytl = 0.02 * (yr[1] - yr[0])
  29. xaxis -> SetProperty, TICKLEN=xtl
  30. yaxis -> SetProperty, TICKLEN=ytl
  31.  
  32. ; Create model and view objects to contain the object tree, and
  33. ; a window object to display it:
  34. mymodel = OBJ_NEW('IDLgrModel')
  35. myview = OBJ_NEW('IDLgrView')
  36. mywindow = OBJ_NEW('IDLgrWindow')
  37. mymodel -> Add, myplot
  38. mymodel -> Add, xaxis
  39. mymodel -> Add, yaxis
  40. myview -> Add, mymodel
  41.  
  42. ; Use the SET_VIEW procedure to add an appropriate viewplane rectangle
  43. ; to the view object.
  44. SET_VIEW, myview, mywindow
  45.  
  46. ; Now, display the plot:
  47. mywindow -> Draw, myview
  48.  
  49. val=''
  50. READ, val, PROMP='Press <Return> to Redraw.'
  51. mywindow -> Draw, myview
  52.  
  53. READ, val, PROMP='Press <Return> to destroy objects.'
  54. OBJ_DESTROY, mywindow
  55. OBJ_DESTROY, myview
  56.  
  57. END
  58.